//
//  vdTexManager.h
//  Void Dead
//
//  Created by Sidney Just on 17.11.09.
//
//  Copyright © 2009 by Sidney Just
//  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
//  documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
//  the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 
//  and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
//  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
//  PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 
//  FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
//  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

#import <Foundation/Foundation.h>

#import "vdTexNode.h"

//\cond
typedef struct {
	id delegate;
	SEL callback;
	NSString *suffix;
} vdTextureLoader;
//\endcond

/**
 * This class handles the loading and deleting of textures.
 * <br>When using this class to load textures, the texture will be only one time in the memory. Everytime you try to load a already loaded texture, the vdTexManager will return the pointer
 * of the prior loaded texture.
 **/
@interface vdTexManager : NSObject {
	@private
	vdTexNode **textures;
	int		  count;
	
	vdTextureLoader		*loader;
	int						loaders;
}


- (BOOL)registerSuffix:(NSString *)suffix withClass:(id)_class andSelector:(SEL)selector;
- (void)unregisterSuffix:(NSString *)suffix;

/**
 * Loads the given texture, or, if the texture is already loaded, returns the pointer to the existing texture.
 @param aFile Name of the texture file (eg. "Test.png") in the main bundle.
 @return Pointer to the loaded texture
 **/
- (vdTexNode *)loadTexture:(NSString *)aFile;

/**
 * Deletes the vdTexNode which contains the texture file.
 @remark If the texture isn't loaded via the vdTexManager, this functions does nothing!
 @param aFile The name of the texture in the main bundle.
 **/
- (void)deleteTexture:(NSString *)aFile;

/**
 * Deletes the given vdTexNode
 @remark If the texture isn't loaded via the vdTexManager, this functions does nothing!
 @param aNode The node that should be deleted
 **/
- (void)deleteTextureNode:(vdTexNode *)aNode;

/**
 * Removes all unsuded textures
 @return The amount
 **/
- (int)removeUnusedTextures;

/**
 * Creates (if needed) a sharedManager and returns it.
 @return Pointer to the sharedManager.
 **/
+ (vdTexManager *)sharedManager;

@end
